import { DamageType, SkillType } from '../types';

export abstract class BaseSkill {
  id: string;
  name: string;
  type: SkillType;
  damageType: DamageType;
  probability: number;
  cooldown: number = 0;
  duration: number = 0;
  currentCooldown: number = 0;
  currentDuration: number = 0;

  constructor(
    id: string,
    name: string,
    type: SkillType,
    damageType: DamageType,
    probability: number = 1,
    cooldown: number = 0,
    duration: number = 0
  ) {
    this.id = id;
    this.name = name;
    this.type = type;
    this.damageType = damageType;
    this.probability = probability;
    this.cooldown = cooldown;
    this.duration = duration;
  }

  canUse(): boolean {
    return this.currentCooldown === 0;
  }

  startCooldown(): void {
    this.currentCooldown = this.cooldown;
  }

  updateCooldown(): void {
    if (this.currentCooldown > 0) {
      this.currentCooldown--;
    }
  }

  abstract execute(source: any, battle: any): void;
}
